Repository navigation
Conversation
`Submodule.iter_items()` reads `submodule.<name>.branch` as a string and turns it into a full ref, so `branch = 1.10` gives `refs/heads/1.10`. When the cached attributes are re-read instead, after `set_parent_commit()` or `_clear_cache()`, `_set_cache_` used `get_value()`, which converts numbers and booleans: `branch_path` became the float `1.1` (the branch name itself is lost), the int `2` or `True`, and `branch_name` raised `TypeError`. A named branch such as `dev` came back as `dev` without the `refs/heads/` prefix that `branch_path` documents. The `gix` backend's `submodule_config()` path converted the same way through `_string_to_value()`. Read the value with `get()` on the CLI path and as-is on the `gix` path, and pass both through `Head.to_full_path()`, as `iter_items()` does. Values that already are full refs are unchanged. A valueless `branch` line, which git itself rejects, is treated as unset on both paths; `iter_items()` used to turn it into `refs/heads/None`. `test_reread_branch_matches_iter_items` sets the branch to `1.10`, `2`, `true`, `dev`, `refs/heads/dev` and a valueless key, and checks that `branch_path` matches between `iter_items()` and both re-read paths. Every value but `refs/heads/dev` fails without this change under the `cli` and `gix` backends, and all pass with it. Agent-Model: claude-opus-5-5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I am a Claude (Opus 5.5) agent working through the contributor's account.
I found this while fixing
branch = .for submodules (#2362), whereupdate()had to re-normalize the branch it got back afterset_parent_commit().Submodulereads itsbranchsetting two different ways.iter_items()turnsbranch = 1.10intobranch_path == "refs/heads/1.10". Afterset_parent_commit()or_clear_cache(), the value is re-read withget_value(), sobranch_pathbecomes the float1.1andbranch_nameraisesTypeError.2becomes an int,truebecomesTrue, anddevcomes back without therefs/heads/prefix. Thegixbackend'ssubmodule_config()path converts the same way. Release branches named like1.10are the most likely to hit this.Read the value as a string on both paths and pass it through
Head.to_full_path(), asiter_items()already does. Full refs such asrefs/heads/devare unchanged. A valuelessbranchline (which git rejects) now counts as unset on both paths. Before,iter_items()gaverefs/heads/Nonefor it and a re-read raisedTypeError.test_reread_branch_matches_iter_itemschecks1.10,2,true,dev,refs/heads/devand a valueless key after both re-read paths. Every case exceptrefs/heads/devfails without the change and passes with it, under bothGIT_PYTHON_BACKEND=cliandgix. The full test suite passes under both backends. Ruff check and format pass, and mypy reports no issues. Tested only on Linux with Git 2.56.0.No changelog entry, as with #2351.